<template>
	<view class="community" @click="navigatorTo">
		<view class="title">
			{{title}}
		</view>
		
		<view class="info">
			{{info}}
		</view>
		
		<view class="pub_date">
			{{pub_date}}
		</view>
	</view>
</template>

<script>
	export default {
		name:"community-item",
		data() {
			return {
				
			};
		},
		methods:{
			navigatorTo(){
				const allow = ['navigateTo','switchTab']
				if(!this.url)return
				if(!allow.includes(this.type)){
					throw new Errow(this.$options.name + '组件：type类型不在' + 在allow.join('、'))
				}
				console.log(this.url)
				uni.navigateTo({
					url:this.url
				})
			}
		},
		// 数据是由父组件传递过来的
		props:{
			title:{
				type:String,
				required:true
			},
			info:{
				type:String,
				required:true
			},
			pub_date:{
				type:String,
				required:true
			},
			url:{
				type:String,	
			},
			type:{
				type:String,
				default:'navigateTo'
			}
		},
		
	}
</script>

<style lang="scss" scoped>
  .community {
  		width: 100%;
  		height: 320rpx;
  		background-color: #fff;
  		border-radius: 16rpx;
  		margin-top: 20rpx;
		// 不加这个会把盒子挤出去
  		box-sizing: border-box;
  		padding: 30rpx;
  
  		.title {
  			font-size: 32rpx;
  			color: #333;
  			line-height: 1.5;
  		}
  
  		.info {
  			margin-top: 20rpx;
  			color: #686868;
  			font-size: 28rpx;
  			line-height: 1.5;
  		}
  
  		.pub_date {
  			color: #BDBDBD;
  			font-size: 24rpx;
  			margin-top: 30rpx;
  			line-height: 1.5;
  		}
  	}
</style>